#ifndef PARTICLE_SYSTEM_H
#define PARTICLE_SYSTEM_H

#include <QVector3D>

const int POSITION_COMPONENT_COUNT = 3;
const int COLOR_COMPONENT_COUNT = 3;
const int DIRECTION_COMPONENT_COUNT = 3;
const int STARTTIME_COMPONENT_COUNT = 1;
const int TOTAL_COMPONENT_COUNT = (POSITION_COMPONENT_COUNT
        + COLOR_COMPONENT_COUNT
        + DIRECTION_COMPONENT_COUNT
        + STARTTIME_COMPONENT_COUNT);
const int STRIDE = TOTAL_COMPONENT_COUNT * sizeof (float);

class ParticleSystem {
    public:
        ParticleSystem(const int particleCount);
        virtual ~ParticleSystem();

    public:
        void addParticle(const QVector3D &particle
                    , const QVector3D &color
                    , const QVector3D &direction
                    , const float startTime);
        inline const float *vertexData() const {
            return m_particles;
        };
        inline size_t vertexDataByteSize() const{
            return m_currentParticleCount * STRIDE;
        };
        inline int currentParticleCount() const {
            return m_currentParticleCount;
        };

    public:
        // for debug
        void showParticles(); 
        QVector3D getParticlePosition(size_t idx);
        // for debug end

    private:
        float *m_particles = nullptr;
        size_t m_maxParticleCount = 0;
        size_t m_currentParticleCount = 0;
        size_t m_nextParticle = 0;
};
#endif // PARTICLE_SYSTEM_H
